package pers.jason.wppm.edge.system.security.userdetails;

import lombok.Data;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import pers.jason.wppm.api.entity.auth.User;

/**
 * @ClassName: UserDetailsInfo
 * @Author: JZH
 * @Date: 2019/1/17 12:10
 * 提供给spring security框架使用
 */
@Data
public class UserDetailsInfo extends org.springframework.security.core.userdetails.User implements UserDetails {

    private String nickName;

    public UserDetailsInfo(User user, String roleStr) {
        super(
                user.getLoginName(), user.getPassword(), user.getEnable(), user.getAccountNonExpired()
                , user.getCredentialsNonExpired(), user.getAccountNonLocked()
                , AuthorityUtils.commaSeparatedStringToAuthorityList(roleStr));
        this.nickName = user.getUserName();
    }


}
